﻿using System;
using System.Collections.Generic;

namespace BasicHttpSohu
{
    /// <summary>
    ///User 的摘要说明
    /// </summary>
    public class User
    {
        public string id;
        public string screen_name;
        public string name;
        public string location;
        public string description;
        public string url;
        public string profile_image_url;
        public bool _protected;
        public string followers_count;
        public string friends_count;
        public DateTime created_at;
        public string favourites_count;
        public string statuses_count;
        public bool following;
        public bool verified;
        public bool contributors_enabled;
    }
    /// <summary>
    /// Comparer class used to perform the sorting of the query parameters
    /// </summary>
    public class UserComparer : IComparer<User>
    {
        #region IComparer<QueryParameter> Members

        public int Compare(User x, User y)
        {
            if ((!x.verified && !y.verified))
            {
                // 朋友数越多，分值越小
                int xFriends = int.Parse(x.friends_count);
                int yFriends = int.Parse(y.friends_count);
                return yFriends - xFriends;
            }
            else if (x.verified && y.verified)
            {
                // 认证用户，粉丝越多，分值越大
                int xFollower = int.Parse(x.followers_count);
                int yFollower = int.Parse(y.followers_count);
                return xFollower - yFollower;
            }
            else
            {
                // 认证用户大于非认证用户
                return x.verified ? 1 : -1;
            }
        }

        #endregion
    }
}